package com.yixing.tech.wcs.controller;

import com.yixing.tech.common.hikservice.rcs.RCSResponse;
import com.yixing.tech.common.hikservice.rcs.RCSTaskCallback;
import com.yixing.tech.wcs.domain.dto.RCSARFBCallback;
import com.yixing.tech.wcs.domain.dto.RCSARFBResponse;
import com.yixing.tech.wcs.service.ICallbackService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * RCS回调接口服务
 * */
@RestController
@CrossOrigin
@RequestMapping(value = "/tbea/ic/rcs/callback")
@Slf4j
public class RCSCallbackController {

    @Resource
    ICallbackService callbackService;

    @PostMapping("/action")
    public RCSResponse callback(@RequestBody RCSTaskCallback rcsTaskCallback) throws RuntimeException {
        RCSResponse response = new RCSResponse();
        log.info("rcsTaskCallback: {}", rcsTaskCallback);

        /** 回调逻辑处理 */
        callbackService.rcsTaskCallback(rcsTaskCallback);

        response.setCode("0");
        response.setMessage("请求成功");
        return response;
    }

    /**
     * 校验料箱是否可入库
     * @param callback
     * {
     *     "reqCode": "请求编号",
     *     "reqTime": "请求时间戳",
     *     "wbCode": "工作台/工作站呼叫号",
     *     "ctnrCode": "料箱号"
     * }
     * */
    @PostMapping("/applyReturnForValid")
    public RCSResponse applyReturnForValid(RCSTaskCallback callback) throws RuntimeException {
        RCSResponse response = new RCSResponse();
        log.info("applyReturnForValid: {}", callback);



        response.setCode("0");
        response.setMessage("请求成功");
        return response;
    }

    /**
     * 申请回库仓位
     * @param callback
     * {
     *     "reqCode": "请求编号",
     *     "reqTime": "请求时间戳",
     *     "data": [{"ctnrCode":"料箱号"}]
     *     "wbCode": "工作台/工作站呼叫号",
     *     "groupCode": "组号"
     * }
     * @return RCSARFBResponse
     * {
     *     "": "",
     *     "": "",
     *     "": "",
     * }
     * */
    @PostMapping("/applyReturnForBin")
    public RCSARFBResponse applyReturnForBin(RCSARFBCallback callback) throws RuntimeException {
        RCSARFBResponse response = new RCSARFBResponse();
        log.info("applyReturnForValid: {}", callback);


        response.setCode("0");
        response.setMessage("请求成功");
        return response;
    }
}
